{% extends "course/nav.html" %}
{% block title %}HomePage{% endblock %}
{% block content %}
    {% load static %}
    <link href="{% static 'css/list.css' %}" rel="stylesheet">
    <div class="main-container">
        <div class="main-bar">
            <form class="search-form" method="post">
                {% csrf_token %}
                {% if view_kind == "student" or view_kind == "teacher" %}
                <input class="input" id="search-key" type="text" name="search" {% if search_key != None %}value="{{ search_key }}" {% endif %}/>
                <input class="button" type="submit" value="搜索人员" />
                 {% endif %}
            </form>
             {% if view_kind != "student"%}
                <input class="button right-button" type="button" value="学生"  onclick='window.location.replace("{% url 'view_personnel' 'student' %}")' />
            {% endif %}
            {% if view_kind != "teacher"%}
                <input class="button right-button" type="button" value="教师"  onclick='window.location.replace("{% url 'view_personnel' 'teacher' %}")' />
            {% endif %}
        </div>
         <h3>{% if view_kind == "student"%}
                学生人员表
            {% elif view_kind == "teacher"%}
                教师人员表
            {% endif %}</h3>
        <table class="item-list course-list">
            <thead>
                <tr>
                 {% if view_kind == "student" %}
                    <th class="student-name">姓名</th>
                    <th class="student-gender">性别</th>
                    <th class="student-number">学号</th>
                    <th class="student-email">邮箱</th>
                    <th class="student-operation">操作</th>>
                 {% elif view_kind == "teacher" %}
                    <th class="teacher-name">姓名</th>
                    <th class="teacher-gender">性别</th>
                    <th class="teacher-number">教师号</th>
                    <th class="teacher-email">邮箱</th>
                    <th class="teacher-operation">操作</th>>
                 {% endif %}
                </tr>

            </thead>
            <tbody>
            {% if view_kind == "student" %}
                {% for student in stu_list %}
                <tr id="student-id-{{ student.id }}">
                    <td class="student-name">{{ student.name }}</td>
                    <td class="student-gender">{{ student.gender }}</td>
                    <td class="student-number">{{ student.grade}}{{student.number }}</td>
                    <td class="student-email">{{ student.email }}</td>
                    <td>
                        <input class="button" type="button" value="修改"  onclick='window.location.replace("{% url 'student_update'   student.id %}?student_id={{ student.id }}")'/>
                        <input class="button" type="button" value="删除"  onclick='window.location.replace("{% url  'student_delete'  student.id %}?student_id={{ student.id }}")'/>
                    </td>
                </tr>
                {% endfor %}
            {% elif view_kind == "teacher" %}
                {% for teacher in tea_list %}
                <tr id="teacher-id-{{ teacher.id }}">
                    <td class="teacher-name">{{teacher.name }}</td>
                    <td class="teacher-gender">{{ teacher.gender }}</td>
                    <td class="teacher-number">{{ teacher.department_no}}{{teacher.number }}</td>
                    <td class="teacher-email">{{ teacher.email }}</td>
                    <td>
                        <input class="button" type="button" value="修改" onclick='window.location.replace("{% url 'teacher_update'   teacher.id %}?teacher_id={{ teacher.id }}")'/>
                        <input class="button" type="button" value="删除" onclick='window.location.replace("{% url  'teacher_delete'  teacher.id %}?teacher_id={{ teacher.id }}")'/>
                    </td>
                </tr>
                {% endfor %}
            {% endif %}
            </tbody>

        </table>
    </div>
{% endblock %}